﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FileDFS.Utils.PathConfig
{
    [ConfigurationCollection(typeof(PathOption))]
    public class PathOptionsCollection : ConfigurationElementCollection
    {
        public PathOptionsCollection()
            : base(StringComparer.OrdinalIgnoreCase)
        {

        }
        new public PathOption this[string name]
        {
            get
            {
                return (PathOption)base.BaseGet(name);
            }
        }
        protected override ConfigurationElement CreateNewElement()
        {
            return new PathOption();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((PathOption)element).Key;
        }

        //说明：如果不需要在代码中修改集合，可以不实现Add,Clear,Remove
        public void Add(PathOption setting)
        {
            this.BaseAdd(setting);
        }

        public void Clear()
        {
            this.BaseClear();
        }

        public void Get(PathOption setting)
        {
            this.BaseGet(setting.Key);
        }

        public void Remove(string name)
        {
            base.BaseRemove(name);
        }
    }
}
